::Author:Dzlua
::QQ:505544956
::Time:2017/03/09
@echo off

::----------------------------------------
::del spdui files.
if exist "out/inc/spdui/" rd /s /q "out/inc/spdui"
for /R "out/bin" %%s in (spdui*.lib,spdui*.dll) do del %%s /q
for /R "out/lib" %%s in (spdui*.lib,spdui*.dll) do del %%s /q
for /R "build" %%s in (spdui*.*,spdui*.*) do del %%s /q

::----------------------------------------
::del lua4spdui files.
if exist "out/inc/lua4spdui/" rd /s /q "out/inc/lua4spdui"
for /R "out/bin" %%s in (lua4spdui*.lib,lua4spdui*.dll) do del %%s /q
for /R "out/lib" %%s in (lua4spdui*.lib,lua4spdui*.dll) do del %%s /q
for /R "build" %%s in (lua4spdui*.*,lua4spdui*.*) do del %%s /q

::----------------------------------------
::编译release版本所有库
xmake f -m release -F spdui.lua
xmake -r -F spdui.lua

::编译debug版本所有库
xmake f -m debug -F spdui.lua
xmake -r -F spdui.lua

::----------------------------------------
::创建目录
if not exist "out/bin/" md "out/bin"
if not exist "out/lib/" md "out/lib"

::----------------------------------------
::复制.lib文件到lib
for /R "build" %%f in (spdui*.lib,spdui*.dll) do copy %%f "out/lib/%%~nxf"
::复制.dll文件到bin
for /R "build" %%f in (spdui*.dll) do copy %%f "out/bin/%%~nxf"

::----------------------------------------
::编译release版本所有库
xmake f -m release -F lua4spdui.lua
xmake -r -F lua4spdui.lua

::编译debug版本所有库
xmake f -m debug -F lua4spdui.lua
xmake -r -F lua4spdui.lua

::----------------------------------------
::复制.lib文件到lib
for /R "build" %%f in (lua4spdui*.lib,lua4spdui*.dll) do copy %%f "out/lib/%%~nxf"
for /R "pkg\LuaPlus\lib" %%f in (*.dll) do copy %%f "out/lib/%%~nxf"
::复制.dll文件到bin
for /R "build" %%f in (lua4spdui*.dll) do copy %%f "out/bin/%%~nxf"
for /R "pkg\LuaPlus\lib" %%f in (*.dll) do copy %%f "out/bin/%%~nxf"
::----------------------------------------

echo Done!
echo ------------------------------------
